#StackBounty: #ios #swift #uitableview #slider access stored values from a tableViewCell and save them to firebaseDatabase

Bounty: 50

I have a tableViewCell that has a range slider inside of it. I would like the values from the range slider to be saved to firebase when the user hits handleSave(). I can print out the values when the user slides the range slider inside the tableViewCell, but I cannot save this value from the tableViewCell itself nor can I print the values from the tableViewVC. When I try to print the values from the tableViewVC I don’t see anything in my console. But If I were to print them from my tableViewCell itself then it works just fine.

The code that I am using to try and print the values from my tableViewVC is,

  let costRangeCell = AgeRangeCell(style: .default, reuseIdentifier: nil)
        
        costRangeCell.rangeSlider.minimumValue = 5
        costRangeCell.rangeSlider.maximumValue = 200
        costRangeCell.rangeSlider.lowValue = 5
        costRangeCell.rangeSlider.highValue = 200
        costRangeCell.rangeSlider.minimumDistance = 20
        print(costRangeCell.lowLabel.text)
        print(costRangeCell.highLabel.text)

rangeSlider.valuesChangedHandler = { [weak self] in
        guard let `self` = self else {
            return
        }
        let lowCenterInSlider = CGPoint(x:self.rangeSlider.lowCenter.x, y: self.rangeSlider.lowCenter.y - 30)
        let highCenterInSlider = CGPoint(x:self.rangeSlider.highCenter.x, y: self.rangeSlider.highCenter.y - 30)
        let lowCenterInView = self.rangeSlider.convert(lowCenterInSlider, to: self.contentView)
        let highCenterInView = self.rangeSlider.convert(highCenterInSlider, to: self.contentView)
        
        self.lowLabel.center = lowCenterInView
        self.highLabel.center = highCenterInView
        self.lowLabel.text = String(format: "%.1f", self.rangeSlider.lowValue)
        self.highLabel.text = String(format: "%.1f", self.rangeSlider.highValue)
        print(costRangeCell.rangeSlider.lowValue)
        print(costRangeCell.rangeSlider.highValue)

        return costRangeCell

  }

in the above print statements, I can see the value of the range slider that the user has chosen.

and how I plan to save the data is in the tableViewVc as well.

    @objc fileprivate func handleSave() {
    let costRangeCell = AgeRangeCell(style: .default, reuseIdentifier: nil)
    guard let uid = Auth.auth().currentUser?.uid else { return }
    let docData: [String: Any] = [
        "info": info,
        "info": info,
        "info": info,
        "info": info,
        "info": info,
        "info": info,
        "minSeekingCost": costRangeCell.rangeSlider.minimumValue.self,
        "maxSeekingCost": costRangeCell.rangeSlider.maximumValue.self
        
    ]
    
    self.updateUserDataIntoDatabseWithUID(uid: uid, values: docData as [String : AnyObject])
    print("Finished saving user info")
    self.dismiss(animated: true, completion: {
        print("Dismissal complete")
        print(costRangeCell.rangeSlider.lowValue)
        print(costRangeCell.rangeSlider.highValue)
    })
}

when I try to see what the value is being printed here, it just shows 0 and 1 not the actual number of the rangeSlider

and my ageRangeCell is

class AgeRangeCell: UITableViewCell {

let rangeSlider: AORangeSlider = {
    let slider = AORangeSlider()
    slider.minimumValue = 0
    slider.maximumValue = 100
    slider.stepValue = 5
    return slider
}()

var user: User?
let lowLabel = UILabel()
let highLabel = UILabel()

override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
    super.init(style: style, reuseIdentifier: reuseIdentifier)
    commonInit()
}
required init?(coder: NSCoder) {
    super.init(coder: coder)
    commonInit()
}
func commonInit() -> Void {
    
    lowLabel.textAlignment = .center
    lowLabel.frame = CGRect(x:0, y:0, width: 60, height: 20)
    
    highLabel.textAlignment = .center
    highLabel.frame = CGRect(x: 0, y: 0, width: 60, height: 20)
    
    [rangeSlider, lowLabel, highLabel].forEach {
        contentView.addSubview($0)
    }
    
    rangeSlider.translatesAutoresizingMaskIntoConstraints = false
    let g = contentView.layoutMarginsGuide
    NSLayoutConstraint.activate([
        rangeSlider.topAnchor.constraint(equalTo: g.topAnchor, constant: 20.0),
        rangeSlider.leadingAnchor.constraint(equalTo: g.leadingAnchor, constant: 20.0),
        rangeSlider.trailingAnchor.constraint(equalTo: g.trailingAnchor, constant: -20.0),
        rangeSlider.heightAnchor.constraint(equalToConstant: 40.0),
    ])

    let c = rangeSlider.bottomAnchor.constraint(equalTo: g.bottomAnchor, constant: 0.0)
    c.priority = UILayoutPriority(rawValue: 999)
    c.isActive = true



    }
    
}
}

When the print statement is inside of the ageRangeCell, I can successfully print the values of the range slider. But when I try to print the rangeSliders value inside of the tableViewVC it is not working. The only way for me to save this information to firebase is if I had access to its value. What am I missing? If I can print the statements inside of the tableViewVC I can then save them to the database.


Get this bounty!!!

#StackBounty: #php #magento-1 #localisation #slider #hreflang Product names are randomly translated in Magento widget

Bounty: 50

I’ve implemented a custom product slider in my Magento store. Sometimes the product titles in the slider are in English instead of Dutch on the Dutch storeview.

When I empty the cache everything works normal (titles back to Dutch) for about 1-2 hours and then after a period of time, the product titles go back to English.

This is the code that is used for the product collection in the sliders:

protected function _getProductCollection()
{
    $productCollection = null;

    $category = $this->getCategory();
    if ($this->getCategory() != null && $category->getId()) {
        $productCollection = $category->getProductCollection()
            ->addStoreFilter()
            ->setPageSize(11)
            ->setCurPage(1);

        Mage::getSingleton('catalog/product_visibility')
            ->addVisibleInCatalogFilterToCollection($productCollection);

        $this->_addProductAttributesAndPrices($productCollection);
    }

    return $productCollection;
}

Sidenote: We’ve recently implemented a hreflang module in our store. After this implementation, the problems seem to have started.


Get this bounty!!!